Copied from flynn