Corrected function for establishing data base connection - hopefully works now...
Added comments, cleaned up some unused functions