diff --git a/asterisk.c b/asterisk.c
index f74d0acb25339c968952452a4dff218eafdb35f9..690ab90c50fecfb29b9969789137a145ae6f1ea9 100755
--- a/asterisk.c
+++ b/asterisk.c
@@ -13,7 +13,6 @@
 
 #include <unistd.h>
 #include <stdlib.h>
-#include <sys/poll.h>
 #include <asterisk/logger.h>
 #include <asterisk/options.h>
 #include <asterisk/cli.h>
diff --git a/channel.c b/channel.c
index 2b9c877bfbb8b28cff42f08159694133bece8ea0..004468a62ac89b285ec8de2fe575ee5301fc494e 100755
--- a/channel.c
+++ b/channel.c
@@ -19,7 +19,6 @@
 #include <errno.h>
 #include <unistd.h>
 #include <math.h>			/* For PI */
-#include <sys/poll.h>
 #include <asterisk/pbx.h>
 #include <asterisk/frame.h>
 #include <asterisk/sched.h>
diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index 4644bf0956e38792cf3bc51061211f658f909909..2a8b95d740cc6e4e6f2e9caebe020e777022ab83 100755
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -1213,11 +1213,17 @@ static void zt_enable_ec(struct zt_pvt *p)
 {
 	int x;
 	int res;
+	if (!p)
+		return;
 	if (p->echocanon) {
 		ast_log(LOG_DEBUG, "Echo cancellation already on\n");
 		return;
 	}
-	if (p && p->echocancel) {
+	if (p->digital) {
+		ast_log(LOG_DEBUG, "Echo cancellation isn't required on digital connection\n");
+		return;
+	}
+	if (p->echocancel) {
 		if (p->sig == SIG_PRI) {
 			x = 1;
 			res = ioctl(p->subs[SUB_REAL].zfd, ZT_AUDIOMODE, &x);
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index 6b514befe36807a9da6d053e6c9a9010f69597da..f78c3c15896d4337ee3ee572e3927214edacecce 100755
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -19,7 +19,11 @@
 #include <asterisk/chanvars.h>
 #include <unistd.h>
 #include <setjmp.h>
+#if defined(__APPLE__)
+#include <asterisk/poll-compat.h>
+#else
 #include <sys/poll.h>
+#endif
 
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
diff --git a/manager.c b/manager.c
index a1935ede3497210a1acccf56d8ee88668ef3688a..7bfccaa33b3077a093b17d3d6d3a06f22c080bfe 100755
--- a/manager.c
+++ b/manager.c
@@ -24,7 +24,6 @@
 #include <signal.h>
 #include <errno.h>
 #include <unistd.h>
-#include <sys/poll.h>
 #include <asterisk/channel.h>
 #include <asterisk/file.h>
 #include <asterisk/manager.h>
diff --git a/res/res_agi.c b/res/res_agi.c
index b6f6edebb8066d31478f76fc16b9ff721725cfdf..a0813289a1221f687fa06813ccd1f67faccb67d0 100755
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -31,7 +31,6 @@
 #include <stdlib.h>
 #include <signal.h>
 #include <sys/time.h>
-#include <sys/poll.h>
 #include <stdio.h>
 #include <fcntl.h>
 #include <errno.h>