Manually implemented #826 (partially)