fixed some potential 64bit pointer arithmetic bugs