Fixed a bug, added documentation