Major reorganization to allow for sub documents compilings