Final code + tests