Fixed bugs where dimensions where incorrectly calculated