Added output step, fixed bugs