Refactored code slightly and added png-generating script.