more documentation and removal of unused code