Refactor configuration and clean up code a bit

Change-Id: Iaa48a1c0f14665bc828115ab911da7625696ebc5