core, ui: correctly handle NaN and Infinity values, map to null (fixes #1)