Fixed message passing from bg script,
fixed updating, added replace handling code