Dead code removal and typo fixes