Begin to clone DB logic from SafeBox with refactoring