Faster algorithm, speed solving, replaced ribbon and fixed some bugs