Fix errors flagged by -Wall.
These resulted in segfaults when running in debug mode.