Made a lot of changes to pass tests