Mostly added docblocks and some changes to make testing easier