So the logic is working. Bunch of TODO left.