GH: Added erase feature, modified the logic quite a bit, less buggy.