minor improvements and commenting