Fixed fucntions to work with new input format.
Removed temp files