Refactoring and 1st example.

This commit refactors some code, mostly related to the connection
process, and adds the 1st example app.
The example app is not yet finished, neither are the functionalities it
tries to demonstrate.