Two bug fixes and minor clean-up