Refactoring Stargate state