Refactor/cleanup argument parsing functions