Fix replacing items in containers. Code cleanup needed!