Re-factor DB Stuff

Re-factored a bunch of DB stuff

mist.dbUpdate() split into two functions

co-routine introduced for adding data to db files

moved a bunch of stuff around