Remove unused import and variable.
Fix runtimeerror and removed unused modules.
Put output stuff into new formatter classes.