Fix issues when spacing is not a multiple of base spacing

Needs tests