Make CreateHeightMap less vulnerable for stack overflows and fix a small bug in CreateWidthMap