Code cleanup and inline docs
More inline docs