Read as much as possible in one go (cosmetically reworked version of patch by Jesper Louis Andersen).
merge bug25520 into default