cleanup and moved some stuff to common

Change-Id: I5ac3a3a29cbee35f011cdd4e5f6e0ed6587ddba9