integrate @orihoffer's tweaks