further document the code and remove two unnecessary flags