Shanchen

This is a variety of small fixes.