Minor changes to CocosDenshion

Improved logging, fixed issue reported by Walzer and add some guards against memory corruption.