Minor optimizations for parsing and XML doc generation