Bug fixes and warning cleanup.