Fixed bug in runStageExtractor. Reworked main