Merging in master commits that should go in 0.9

This includes some refactors and error handling work that should go into 0.9.0-RC2.