reorganizing and splitting up into more files for readability
fixing merge conflicts