Fixed undefined behavior
Documentation work