Remove dead codes and a small fix