move state-dependent stuff into states.lua for now