fix a number of issues requested by dchen