Fixed #516; Also reworked data structure for other models