Refactored and improved old code.
Minor changes.