Fix #2460 and #2355 using technique from #2282