Added command-line utility. Refactored code to accomodate.