Refactor

Fixed TODOs and failing tests