Fixed various bugs with tree updates and deletes