Improving temporary file handling

Added a lot of debugging statuses
Making error messages clearer