[engine, module] Many changes required to make things work

Most of the changes required by the recent Qt Declarative updates.

This patch tries to bring use of Heap objects as much as possible. Also
many refactoring changes done in ModuleObject and related classes.