Use dynamic settings, clean up code