fixed some potential aliasing/UB issues