Optional SQL changes related to server version + a minor fix