Added alert and code cleanup