Fix some bugs in the dir() Lua command