patch from ynnsn for #452 and #447