Fix some errors found by tcc

Also remove an unused function.
Reinstate unused function SplitMonotonicAt
Merge pull request #1605 from rrthomas/master

Fix some errors found by tcc