adding upload support
fixing memory leaks