some tidy up. And putting missing quotes in SQL-statements