Fixed issues with alerts and calling delegate at wrong time.: