Incorporating contributions from jsumners and doing some maintenance.
Incorporating upstream changes

This commit incoporates changes made upstream.