Implemented Replace and SubIDs + Code Cleanup