working version of category input and numerous other fixes