Added source code from the thesis