Main work and clean-up