BUG Fixed issues with db generation, many other bugs and errors