Catlib: Removed duplicated code and refactored

Change-Id: Ie90b6432f18e0de768c23db9f4f7e207196235ab
Merge "Catlib: Removed duplicated code and refactored"