Improved environment handling, adding keys for macro handling