Adjusted db connection and main template