added documentation and deleted some old code