Small fixes

Several bug fixes, updated documetation