Add option parsing and clean up code

The code follows more PEP8 guideline now.
Input arguments are parsed and default settings are used.