ENH: performance enhancement, fixes #411