added some additional syncronization and detatchment