Early implementation of replace function. Some more Bug fixes.
Pending 'replace all' and 'replace with reg expressions'