Better random number generator and cleaned a bit