Got rid of some bugs and improved algorithm.
Got rid of some bugs and improved algorithm.