Properly count portals.
Added some debugging information, better use of variables