more comments and simple efficiency improvements