Refactor: move template loader to its own module.