Cleaned up some code so variable are more easily understood.
Removed foreach from Library, since it is a standard component for the framework.