Moved directory handling and other minor changes.