Minor changes in algorithm, documentation