better arg handling and globals