For documentation see
chapter 2 of my master thesis