Various cleanup and fixes.