Fixing 3 bugs and a bunch of tests.