Fixed a search&replace bug, removed some unused code