Refactor helper methods; add more options parsing.