removed unused imports
added thread safety for GDBB

refactored some code