resolved memory leaks in cpu code
resolved memory leaks in gpu code