Almost removed all the dead code