Added template database-handling code.  Broke everything.