0.4.0a merge of nightly

This merges the nightly code for 0.4.0a into the master code branch.