Refactored kernel and added delete statement.