Well that was a stupid mistake that took far too long to debug...