Refactor to prototype, add visited page tracking