Algoritm stability and bugfixes