Coding fix for enchantment, also cleaning up the code