Reduce calls to isinstance and len in cobs
Reduce calls to isinstance and len in cobs

Reorder calls to isinstance() to reduce total number of calls in some
cases. Reduce calls to len() by saving result length.

oliverlee/phobos,oliverlee/phobos,oliverlee/phobos,oliverlee/phobos