added alerts, some code cleanup