essentially same as last commit, but with Moe's merged code.