keypress implemented and some cleanup