Refactor CLI and improve keyring authentication.
Add limited support for typecasting.