Slightly cleaner fix for #504