Refactored gamemode_functions