Added rtti guards for writing arrays and objects.
Simplified primitive translation