Added commenting to explain functions
Made parsing through options more efficient