Container inheritance

Refactored https://github.com/qreal/qreal/pull/653