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)
 [TIMOB-16927](https://jira.appcelerator.org/browse/TIMOB-16927)
 [TIMOB-16767](https://jira.appcelerator.org/browse/TIMOB-16767)
 [TIMOB-16766](https://jira.appcelerator.org/browse/TIMOB-16766)
 [TIMOB-16757](https://jira.appcelerator.org/browse/TIMOB-16757)
 [TIMOB-16750](https://jira.appcelerator.org/browse/TIMOB-16750)
 [TIMOB-16751](https://jira.appcelerator.org/browse/TIMOB-16751)
 [TIMOB-16754](https://jira.appcelerator.org/browse/TIMOB-16754)