This is part question, part issue. I don't really understand the design decision to make functions in derived classes virtual. For example, each layer class derived from Layer has all of its functions (which override the ones in Layer) declared as virtual as well. Why are things done this way? Is the polymorphism here used anywhere beyond the initially derived classes themselves? I think there's typically a (very) slight effect on performance with virtual functions, so it might make sense to use virtual functions only when we know the polymorphism is going to be used.