Bug fix, remove all global variables and use options instead.