Made a couple of perlin functions global so they aren't being redefined
every time an ABM or on_generated is called.  Optimized a number of nil
comparisons ("if x == nil" -> "if not x" and similar).