Fixes for sql database