Refine environment and gate spawning