Fixed bugs and polished output a little