Minor fixes after review:

Implemented input errors handling.
Style fix.