Quaternion: some memory management improvements