a lot of bug fixes and documenation