Fixed iterators on functions that loop through systems

My implementation of for() loops that ran through the systems was horribly
constructed. This new version should work, but I'm concerned about the
dereferencing used by typeid() when checking the type of System in
systems.