Refactored self and fixed foreachDo property leak