No changes in functionality whatsoever, just a few minor changes (e.g. explicit casts) to remove compiler warnings.