Improved state system, added menu functionality