fixed minor bugs and keypress bugs