Command line option parsing, fixes, refactoring...