fixed some minor bugs and added documentation