Added animation, keyboard handling, and optimization