Refactored code to make flow more "clear" hopefully.  Still have issue with index page and "No api url set".