John Holmes's merge

contains all of john's additional code.