housekeeping and added exit handler