Fixed bug in clear_directory (fails if directory does not exist)