Rewrote complementBed to use a slower but much simpler approach. This resolves several bugs with the previous logic.