Refactored texture generation a bit.