Added some code to handle command line options / environment variables. Also
includes some minor test functionality.