fixes for SQL implementation