major rework

fixing overflow problems