Fixed caused of null error

Added in a few safety checks, not many though.

Don't do 1.0/Math.random(),  small chance of game randomly breaking /
using large amount of memory.