Removing unused HTML, updating error handling on alerts