Both of those are related. The icon(s) at the top right aren't randomly selected - they represent the elements that that item has. The error you are receiving is likely because you haven't setup which icons you want to use to represent each element you have in the database. If you go to line 154, you will see this:
# Icons to represent elements of items in the Information screen. Every
# element MUST have an icon.
GI_ELEMENT_ICONS = [132, 2, 4, 14, 16, 12, 138, 137, 104]
You must give every element an icon.
Alternatively, if you don't want to show the elements at all, you would need to go to line 2084 and comment out the following four lines:
item.element_set.each { |i|
x -= 28
draw_icon (ModernAlgebra::GI_ELEMENT_ICONS[i - 1], x, 4)
}