Restructure of script. Separate function for output. Several TODO's added
Read all files in dir code