Convert objects to pretend classes now so that the code can have fewer edge cases.

Reordered the code, modified the error messages slightly.