Added function to delete an directory (including several helper methods). Fixed a bug.