Fix some compiler warnings, add an explicit cast.