Created local structs first_dir/key/degree and second_dir to avoid repetitive map search.
Number of split messages is now a third input paramenter