Refactored native host messaging logic