Improved documentation and small logic.
Improved overall documentation and spruced up some logic here and there.