Refactor input/event system and keep it within 100 line limit