Added safeguards to values in an attempt to stop crashes
Added safeguards, fixing overflows