More docs. Sorting code around. Name changing for more mathematically correct terms in some functions