code cleanup, refactor command line processing.
updated demo