Minor optimization issues and cleanup.