Code for masters thesis.