Added --replace support, changed design