added threading support for the database stuff. alas couldnt test due to internet issues on exeuction. but should work.