Fixes for DB_CUSTOM_V5

Still have minor fixes for logic for INPUTS / OUTPUTS
More than likely will segfault atm