Refactor apcera changes for upstream

Merging the refactored changes for testing