Fixed database and template errors