A caboose is a North American railroad car that is coupled at the end of a freight train. It provides shelter for the train crew at the end of the train, who were formerly required in switching and shunting, keeping a lookout for load shifting, damage to the train, and other potential problems. The caboose served several functions, one of which was as an office for the conductor. The conductor kept the paperwork in the caboose, and it also carried a brakeman and a flagman. The crew could exit the train for switching or to protect the rear of the train when stopped. The caboose was also used as a marker, typically painted bright colors, and often flying flags or bearing red lamps, to physically denote the end of the train. The addition of the cupola, a lookout post atop the car, was introduced in 1863. The lookout post gave the crew good visibility when inspecting the train from the rear. The caboose was also a mobile office for the train crew, and it was a shelter from the elements for railway employees. The use of cabooses began in the 1830s when railroads housed trainmen in shanties built onto boxcars or flatcars. The earliest known printed record of "caboose" used to describe the railcar appeared in 1859 in court records in conjunction with a lawsuit filed against the New York and Harlem Railway.