C topology

Refactor and merge apps/topology.

This pull request depend on #258.  

Commits before 	d0999f3 is part of #258 thus they can be ignored when reviewing this pull request.