Added some comments, cleaned up some Database stuff for templates