Merged with David V's changes