Removes copy&paste code and some bugs were fixed

removes much copy&paste code, saving items in tables instead of inventory slots for "you need:" feature, and it includes a fix to save the text entered in search field