Refactoring of random spawn calculation.