Fix some errors found by tcc

Also remove an unused function.