Frameworks: fix possible NPE

due a race condition this can happen....prevend it

cheers

Change-Id: I65222389c6b0beecaebed915644ab5e800c5f119
and another small fix ...

Change-Id: Ifb699511a800af885dd3dee9b2d25d450d924376