Commit wip

Work in progress on cleaning up code
db interface and complexity need work`