Added simple optimization

Redundant saves and restores of the environment are now removed, if the ENABLE_OPTIMIZATIONS variable is set to #t