# Buggy code
def startup(self, **kwargs):
    self.state = "normal"

    # this sprite is used to display the item
    # its also animated to pop out of the backpack
    self.item_center = self.rect.width * 0.164, self.rect.height * 0.13
    self.item_sprite = Sprite()
    self.item_sprite.image = None
    self.sprites.add(self.item_sprite)

    # do not move this line
    super(ItemMenuState, self).startup(**kwargs)
    self.menu_items.line_spacing = tools.scale(5)

    # this is the area where the item description is displayed
    rect = self.game.screen.get_rect()
    rect.top = tools.scale(106)
    rect.left = tools.scale(3)
    rect.width = tools.scale(250)
    rect.height = tools.scale(32)
    self.text_area = TextArea(self.font, self.font_color, (96, 96, 128))
    self.text_area.rect = rect
    self.sprites.add(self.text_area, layer=100)

    # load the backpack icon
    self.backpack_center = self.rect.width * 0.16, self.rect.height * 0.45
    self.load_sprite("gfx/ui/item/backpack.png", center=self.backpack_center, layer=100)


# Traceback (KeyError)
Traceback (most recent call last):
File "./tuxemon.py", line 60, in <module>
main()
File "/tmp/Tuxemon/tuxemon/core/main.py", line 109, in main
control.main()
File "/tmp/Tuxemon/tuxemon/core/control.py", line 512, in main
self.main_loop()
File "/tmp/Tuxemon/tuxemon/core/control.py", line 573, in main_loop
self.update(time_delta)
File "/tmp/Tuxemon/tuxemon/core/control.py", line 203, in update
state.update(dt)
File "/tmp/Tuxemon/tuxemon/core/states/combat/combat.py", line 156, in update
self.update_phase()
File "/tmp/Tuxemon/tuxemon/core/states/combat/combat.py", line 328, in update_phase
self.handle_action_queue()
File "/tmp/Tuxemon/tuxemon/core/states/combat/combat.py", line 338, in handle_action_queue
self.check_party_hp()
File "/tmp/Tuxemon/tuxemon/core/states/combat/combat.py", line 614, in check_party_hp
self.faint_monster(monster)
File "/tmp/Tuxemon/tuxemon/core/states/combat/combat.py", line 581, in faint_monster
awarded_exp = monster.total_experience/monster.level/len(self._damage_map[monster])
KeyError: <core.components.monster.Monster object at 0x7fb24236ddd0>

# Fixed code
def startup(self, **kwargs):
    self.state = "normal"

    # this sprite is used to display the item
    # its also animated to pop out of the backpack
    self.item_center = self.rect.width * 0.164, self.rect.height * 0.13
    self.item_sprite = Sprite()
    self.item_sprite.image = None
    self.sprites.add(self.item_sprite)

    # do not move this line
    super(ItemMenuState, self).startup(**kwargs)
    self.menu_items.line_spacing = tools.scale(5)

    # this is the area where the item description is displayed
    rect = self.game.screen.get_rect()
    rect.top = tools.scale(106)
    rect.left = tools.scale(3)
    rect.width = tools.scale(250)
    rect.height = tools.scale(32)
    self.text_area = TextArea(self.font, self.font_color, (96, 96, 128))
    print(rect)
    self.text_area.rect = rect
    self.sprites.add(self.text_area, layer=100)

    # load the backpack icon
    self.backpack_center = self.rect.width * 0.16, self.rect.height * 0.45
    self.load_sprite("gfx/ui/item/backpack.png", center=self.backpack_center, layer=100)