remove unused libraries, handle subscribing & unsubscibing