Buildings must be constructed in accordance with the version of the building code that is in effect when an application for a building permit is made. Building inspectors check on compliance of a building under construction with the building code. Once construction is complete, a building must be maintained in accordance with the current fire code, which is enforced by the fire prevention officers of a local fire department. In the event of fire emergencies, Firefighters, fire investigators, and other fire prevention personnel are called to mitigate, investigate and learn from the damage of a fire. Lessons learned from fires are applied to the authoring of both building codes and fire codes.