Final thesis version