Refactor CLI implementation, resolves #27 and resolves #28