Fix some problems with the Perlin implementation