fixes to make sql work