Fixed normalization, added terms sorting