Fix issues disguised by lexical scoping