applied cleanup from M. Hurton and S. Nagy