Some debug output added, no idea why the list is iterating in a weird fashion...