Played about with comments and layout. Global static variables have been initialised. Static functions have prototypes and commentary at the top of the file and implementation at the bottom.