Simplify implementation for #336.