Updated with changes made by Jesse.

Gives much better handling of options as well as better error handling.
Overall much cleaner code that allows for easy exantion.