The skin has three main layers - the epidermis, dermis and subcutaneous layer - that work together to regulate body temperature and protect the body. The epidermis is the outer layer and contains keratinocytes that are continually replaced, as well as melanocytes that produce pigment. The dermis contains sweat glands, hair follicles and sebaceous glands. When the body needs to cool down, the skin's capillaries vasodilate to increase blood flow and transfer more heat to the surface of the skin.