Restructured code, added upload functionality.