Improved fix for #45