Refactoring

Refactoring towards better generalisation and simplified topic handling.