Logic refactoring.

Argument parsing logic is now shorter and clearer.