Added the code to handle parts and quits