Fix Item location bug and some minor refactoring