Re-order parseDocument to check for common cases first