Added file count of directory and cleaned up code