Fixing discovery

Adding PAN controller functionality and sorting out discovery mechanism.