Added Command line parser and code cleanup