proper error handling in ml json wrapper
factor out flag constants, simplify some code
handle command line arguments