Remove debugging messages/replace error messages with exceptions.

TODO: Replace use of std::runtime_error with own exception types so they
can be caught in a sane manner.