Refactored argument parsing into it's own function.