Refactor boltdb access