Organized main update loop into subroutines.