Mysql bugfix

Fixes a problem with adding new items into the database and tidies up some logging