Use getOption and minor code cleanup