Fix input handling, add state cache