Refactor some of the instagram code