Move imports to the top

sys is needed to create args, so I've moved it and all other imports to
the top of the file, i.e. right after the docstring