Rearranged and removed debug code
Implemented deleting temporary files
Implemented deleting unused rows