Implemented the session handling.
lib: using a custom Error type.
Fixed a few things around errors.
Be more careful if the user has made a typo when writing a command.