Algorithm and UI fixes