Fixed bug with not setting delegate correctly