Fixes issue 522. Improves communication security.