Refactoring, added options support