Fix CLI

Fix issue #35 . 

Backported version for the 2.x branch.