Cleaned up code. Changed the switch statement in onFrame to an if-elseif-else statement because of a peculiar problem.