Moved most of the layer logic into Master