Cleaned up and improved option parsing