Bug fixes for mysql handler