improvements and refactoring

Change-Id: Iac8169a57746ba22bcef11febd4cb66f723d252e