Spaghetti code removed. Will create R3 branch and merge with master