fix UBSAN issues