Cleanup and a minor bug fix.