improved (un-)subscription handling, introduced unsubscribe atexit handlers and fixed some small bugs