Lots reorganization. Simplifying functinos and reordering