Fix bugs in compiling and tweak output