correcting life cycle problems and implementing many of the query buttons