Added commenting and did some fixes.