Cleanup and fix for a mutability issue