Cleanup code and remove C-isms.

Change-Id: I09aa2d0d7b95b809ba3da4841c05c04c47d377f8
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>