Speeding up template serialization

Templates are being serialized quite slowly for some reason. Trying to
speed this up with AJAX calls for certain things.