Add Abe's code from commit 5ecf718