minor improvements and better comments