get rid of dead code, fix document view and template