Fix cases where e.g. state has either zero width or height, causing the unit convertion functions would return NaNs.