Fixed pointer casts; removed unused functions; default to std=c99