substantial refactor/cleanup, added discoverViaPortal