Reorganizing files and improving functions 2