Simplified the code a bit.
Minor modifications.