Update to a faster algorithm and dropped some un needed functions.