Refactored Layer class