Start with excluding non-citizens from countries that support terrorism. Proceed onto extensive background checks for the lowliest Muslim enlistee, with red flags for those who have studied Islam in the Middle East, or who are or have been associated with radical Islamic organizations and/or mosques.
Transfer certification of Islamic chaplains to moderate groups who have no history of ties to terrorist groups. Discourage the current recruitment techniques openly admitted by Islamic chaplains, and stop giving them soapboxes in the name of "tolerance."
In short, take the lessons learned from these cases and shore up our defenses, instead of hiding behind the same political correctness that gave us 9/11.