SQL handling moved to own thread, got rid of some unused imports