More comments and moved environment check logic.