Code structure and options refactoring