Refactored FreeMarker integration