Added search depth control and improved simplify_solutions

Also added comments to assist with reading code.