Refactor and re-implement

Refactors some of the code into modules. One major change is using gradient
coherent noise for perlin noise generation, which tends to have fewer
artifacts.