Refactor CLI and bin