Correct bugs, close issues, and some improvements