Refactor environments and builtins

Separate environment functions into module.
Rework initial environment generator to be more concise.