Minor fixes for algorithm