Remove dead code

Remove some unused functions and unused statics related code.