some minor improvements. rank added