Fixed problem with file sheduled file upload. Fixed some memory leaks Fixes #1187