Use inherits() to ascertain class information

This series of commits changes functions to use `inherits(foo, "class")` instead of `class(foo) == "class"` or similar constructs.

(I also removed a couple of `return()`s)

The changes look more extensive that they are as my editor has a different indent width than Simon's and I streamlined the code a little as I was editing.