Fixed various retain cyles issues and bugs