Added a soft cache using set_transient.
Code refactoring.