Fix bugs and doc issues