Misc bug fixes causing slowdown on MSSQL
Bug fixes for MSSQLSpatial (internal conf)