boyfriend defensive about ex.

So I have been in a relationship for about a year now and it has been amazing, he is a true gentle man. Until something about his ex comes up. Last week I found messages from her on his phone from May, (we had been together for 6 months then) and they were pretty friendly messages. Meaning flirtatious. I asked him about it, he said "I was just trying to be nice to her", then he got pissed off at me because I didn't like that they were flirtatious messages and that it made me feel like shit. Then tonight I was getting pictures off his phone and sending them to mine (I wanted to use them for a little first year anniversary surprise) and I come across multiple photos of them. He was next to me when I saw them and just said "so that's why you want my phone you just want to go through it", then to say sorry he just yells "I'm sorry" and then sighs. They have been broken up going on two years so I don't understand why he gets so defensive over her, I have never in any why disrespected her. So for him to act like that tears me apart. 
For anyone that does read this alll the way through, thank you.. I just needed to rant and get it all off my chest to someone other than my best friend. 
If you do leave a reply please tell me what you think. I do love him, and I know that he does love me but I'm just hurting right now.