Restored parts of old code