Refactored function calls to logical locations

Moved all inter-object function calls into the engine.
More comments and cleanup.