Stringbuilder performance improvements.
Made caches thread-safe where needed.