Memory allocation reduced (with speed optimisation where possible).

git-tfs-id: [https://tfs.codeplex.com:443/tfs/TFS13]$/xBIM/XbimFramework/Head;C36158