First part of a fix for #104, this uncovers another issue though.