Refactored template loading to its own class for performance