Start with removing void pointers and C-style casts. This will let compiler do sanity checks.