Convergence and Optimality of hp-AFEM