Final version of thesis