Removed some duplicate code in the parser + other minor cleanups

The main change was adding an 'optional' param to parseGroup removing the need for parseOptionalGroup.  There are some other minor changes which I'll comment below.