Fixing a few bugs based on the latest changes.