Refactoring game functions.