Add parts of old code