Removed some unused code, added another replacement check for some odd cases