Fix warnings

Fix various warnings. Need to spend some time doing this properly, so
I'll raise a separate issue to address this.