Fixed some bugs with mysqli implementation