Refactored layer class