Code clean up, rearrangement, renaming