cleanup
cleaup and refactoring
add commandline options; cleanp.