Probably one of the more complicated changes for #81.