Removed unnecessary flags. Fixed endProcessing implementation.