Implement #22 from upstream