some tweaks and cleanups

Hi Andrey - 

I think this is working pretty well and is already useful.  This will serve as a great template for additional improvements.

-Steve