Improve state & controls handling (fixes #6)