Fixing some bugs in inmemory