Fixes name collision issue, which is not directly related to this patch but has an additional case in debug mode. Added regression test.