bug fix and minor cleanup

Change-Id: I29b4135bcfa1d286fe97b3a54edb3b96fb0399d3