General performance and stability fixes to the platform

This PR is necessary to continue with the rest of the bugs. After testing the platform with already built apps, a memory leaks and crashers have been found. This PR takes care of those.

This also fixes [TIMOB-16777](https://jira.appcelerator.org/browse/TIMOB-16777)