Several fixes to get the template compilation working with the new
DB-based resource store