Functions improved. Refractor.