Added some functionality as well as part of two failing tests.