Code optimalization + update tree bug fix