Improvements

Code refactoring, bugfix, typo, and improve output messages verbosity.