Framework: clean up QS to reduce memory leaks in special conditions

PS2: adapted to slim
PS3: clean up

Change-Id: I4cf516da95abff6d493c36158e916a6fc35741d5