moved db connection creation to another method
minor fixes
added editing functions to template
added editing functions to main unit