Thanks to Evgeny for much of the work and suggestions from Boger Wang. Co-authored-by: Evgeny Gagauz <evgenij.gagauz@gmail.com>