Add upload functionality. Minor fizes and formatting.