More clean up and started working on the layer's logic