Refactored and updated game functionality