Patch to make attach idempotent and make cursor type configurable