Wrote documentation, minor code improvements.