Got rid of sleep 10000 and replaced it with loop that ends when the tmpfile is gone. Added remove of tmpfiles and other cleanup.
Removing debug code that shouldn't be here.
Updated readme for bugfixes