Refactor Main engine component

Change: improve code organization.
New: add missing documentation.