Final version of the thesis