Various cleanup and code changes.