Added comments and bugfix: correctly using delete[] now