fixed some overflow issues