fix some gem bugs