Initial master thesis version.