Improved the randomHeights algorithm and fixed a cell selection bug