The problem might be present in the code but it would be best for me to test this and see the result that you are getting. If you can post a copy of the db and the files let me know and I can open a ticket so that we can exchange those files in private.
Rite now I'm not sure why it is not working when you have the users repeated like this.