code cleanup, dependencies reordering