Fixed some minor bugs. Now computes correctly.