pass mysql connection objects to functions; minor cleanup