I read through the parts where you were looking at item v. available. Funny enough, that led me to the unequip_familiars() function which is never called, as well as terraium_amount(). It seems like you planned to just unequip terrarium familiars originally, but handling of the terrarium itself...