Finished first full version of solving algorithm.