My copy of the Code says nothing about everyone and his brother being allowed legal prey, that being killers of innocents. The unwritten commandment is that it applies only to Dexter. Doakes qualified by virtue (an ironic use of the word) of his black ops background. Those ops are kept in the black because they aren't morally acceptable (or weren't, in slightly more innocent times.) The homicidal teenager's victim wasn't a murderer. More importantly, the kid was BSing Dexter, who fell for it because his supposedly nonexistent emotions swayed him. The Castillos victims were all guilty. Running from La Migra is why they fell into the trap. And that is surely true of lots of victims. If the prime offense in the Code isn't murder, then it doesn't make sense at all, not even in the very limited Crazy Harry way.
And the elephant in the room that the show has kept dodging is that Harry was crazy, and his Code wasn't helping Dexter but the most grotesque form of child abuse, turning him into a vigilante killer to act out his own murderous fantasies. Facing this would be Dexter's last step in coming to terms with his repeatedly demonstrated desire for a sane and decent life. And realizing what Harry was would be requisite to Deb growing up.
If Dexter gets to keep on killing endlessly, with Deb's approval, is the reason to throw the TV set out the window.
Dexter passing lethal judgment on himself and committing suicide (or surrendering, to go to Death Row) is indeed uncomfortable, but that is the true dramatic tension in the show. Or was. Killing Rita gutted a lot of that.