Thread safety annotation
Fix bug with forgetting to close output stream
Remove dependency on BridgeDb, instead copy the needed classes over