Some mods to deal with int overflow, not working yet