Added some ability to be called from command line.