Fix bug where dying would freeze the game, refactor inventory code, fix inventory bugs