Undoing a133963d0e45a4d3b51f87649bb5854e72a638f1. Hopefully will fix #521