incorporate @smarx's changes.