Merged Troy's fixes