Modularize and add CLI.