~ Some changes, rearrange code