Replaced copy for loops with appropriate calls from the algorithm class and added better build rules in the Makefile