added command-line interface; minor remodeling