Implemented TODOs.
Added tests.