Added left factoring, fixed bugs.