Filled out implementation of refdb