Fixing the code

Added comments, changed the find.element path for agents allocation and
listings. It was a mess this week and I could not commit each change.
The idea is that the tests work now.