Improved loops again, no recursion problems and the performance isn't that bad.