Restricting Dyck Paths and 312-avoiding Permutations