Reworking main code layout