Major changes to populate and erase functions.