Reduce some duplicate code by abstracting some simple parsing routines