TODOs resovled: documentation added.