fixes #2366 Checks for type before casting to avoid exception.
(cherry picked from commit a148c371a5cef5069f930db61639d84beb344416)
Remove line of nonsense code.
(cherry picked from commit ed06cf53d266a186452b23ac6b1857cbb50aed3d)
fixes #2448 Treats null Integers the same as null Double to dodge null pointer exception.
(cherry picked from commit 30117478354621e152eb445d606de95d1cf8ba11)