Bug fixes. Now runs all tests :)