switch QList<> to QVector<> and add some guards against out of range indices