#23: Adds validations to avoid crashes due to unhandled NaNs and Infinities