Merged in S. Fegan's code.  DO NOT USE THIS COMMIT.