added command line interface, enhanced some other functionality