Remove dead code, and global function test