Removed two subtle bugs.