fixing some bugs and doc problems