Big rewrite, added sensible directory upload.