more performance improvements to serialize