SQL/Misc: Misc fixes