Tidy up and added quit support