refactor for multi-feed, add comments, cleanup formatting