Initial sql fixes, but it still does not work