misc bug fixes, add command line support