Back end: Refactorised the internal storage classes. Fixes #65.