partial merge of Dan's changes from last year