typo fix
refactoring to pass environments through expressions
commenting and deleting redundant code
tidy warnings