Improve option and error handling