SQL Server compatibility and minor improvements