Moved the threading stuff and the database stuff into their own namespaces

Signed-off-by: Toon Schoenmakers <nighteyes1993@gmail.com>