Edits, rearrange code