He could just be normally figuring out his independence. It's a transitional age for it. Try to stay positive with him, he sounds like he likes to joke and play around.
I also know what it's like to see the ex's traits in the kids, it can be so frustrating & discouraging. but remember he has you in him too. And you're teaching him good things.
Sorry kind of a short response, I'm sleepy.