Unsubscribe from topic

Currently the wrong id is being sent when you unsubscribe from a topic and the channel remains open.

+ Consistent line endings and some code re-factoring in the second commit