fixed tricky lambda and module scoping bugs