merge recent fixes from master to prevent mysql errors in sGMS