Massive refactor to implement Layers