The most effective method of handling nasty comments from flatmates is simply to ignore them. Get yourself a nice personal music player with good quality headphones and wear these around the apartment. It may sound rude, but you can listen to music whenever you want and putting the volume up high will help ensure that you do not have to listen to any nasty comments from flatmates.
Even though you may share the same space, you probably have your own bedroom. Instead of sitting in the television or common room, sit in your bedroom and keep the door closed. This will send out a strong signal that you do not want to be disturbed. By staying in your room you will be effectively keeping distance from any type of nasty comments from flatmates.
If the lease or rental agreement is under your name then you are in luck. You can simply get rid of a flatmate that is constantly giving you nasty comments. Just give notice to your flatmate before you replace him or her. You can place an ad in the paper stating your desire to find a new flatmate.
If you are not listed in the rental agreement or lease then you might want to find a new place to live. Search through the classified ads and find a decent place for yourself or find some new flatmates to move in with.
Talk it out:
If some of these options are not viable then it is a good idea to sit and have a serious talk with your flatmate. Tell him or her that you do not appreciate their nasty comments and that you are getting irritated by their attitude. A serious conversation like this can usually work wonders as your flatmate might not have known how you actually feel about the comments. By opening up some communication you can avoid any further complications and hopefully reduce the amount of nasty comments coming your way.