fixed some overflow issues. Still not entirly fixed, but better than before.