Refactored ext/dba (tests passes, but segfaults need to be fixed)