toroco.lua: Added more error checks