Fix cast issues in Lab calculation