Bring in Greg Allen's extensions and update to merge against current master

This is basically Greg's changes as-is, tweaked to merge cleanly against deec9c40 (which incorporates 0e78ba06).