Merge upstream changes

Test: keep fork in sync with upstream via Github web interface.
(based on http://stackoverflow.com/a/21131381)