big refactoring

Change-Id: I47bb33d408570855f15911426841abf09a67c48d