Improved state storing
Better keyboard handling