fix null termination for environment
cleanup