Did some re-factoring to share code with upcoming (multi stream) packager. Change-Id: I2b3845e48ba6aa63a95ecc276abcb52c8355d8d5