Bug fixes based on Wu's comments.