Refactoring.

Refactored a bunch of code from Game into ElementManager.