Use push_back rather than operator[], which is incorrect in this cases. Unfortunately...