Integrate David's changes, take 2