Workaround for % bug.

This can surely be done more efficiently, but for now this works.