Added debug mode, and wrote the final render functions