Refactor to remove custom tables