Refactored graph datastructure and added graph cloning