Improved game text position calculation.
General reorganization of the source code.

  * Renamed functions to a more self-consistent (though verbose) approach.
  * Fixed and reformatted function comments.
  * Moved some functions around.
Style fixes all around.