Fixed bugs that resulted from refactoring. Some of the tests will need
to be modified yet