Fix major bugs and cleaned output