More code maintenance.

Added Javadocs-style documentation for several methods. Moved some code to more appropriate locations. Refactored some methods and changed the scopes of some methods. No others issues addressed in this commit and game behaviour should remain unchanged.