Fix bug where database will not create or function with current config settings.
Add a TODO and change function for production ready code. (long commit)