cleanup + added commandline code