Fix for #531 and #533