Moved event logic out of player and refactored