Refactor AK Sync

Refactor and improve code quality for AK sync.