Fixed various bugs in the calculation for the offset on the right. #3 completed