added documentation & fixed bugs