Fixed runtime error and environment variables