Added handling of periods and early validation/fixing of input.