Fix warnings.

Most of this will be rewritten anyway, but I was finally sufficiently
annoyed by the warnings now to fix them anyway :)