Refactoring some stuff to make proper option handling easier.