Logging, clean up of environment stuff