Fix 14424 and 14367

[TIMOB-14424](https://jira.appcelerator.org/browse/TIMOB-14424)
[TIMOB-14367](https://jira.appcelerator.org/browse/TIMOB-14367)

Test using https://github.com/appcelerator/titanium_mobile/pull/4627 and https://github.com/appcelerator/titanium_mobile/pull/4628