Refactor + add getopt