Created main(), parse_params() functions

Refactoring for readability:
I moved all code into a main() function.
I created a parse_params() function for a chunk of the main() function.
No functionality should have changed.
This is untested.
Merge pull request #3 from arnimar17/master

Created main(), parse_params() functions.
Merging pull request from arnimar17. Thank you.