Major refactor part I