Minor changes
Increased rigor of algorithm