Moved options-related code to its own module, and extended it a bit