Reorganize code according to what Alex said on 30/10