Fix essential bcs deallocation.
Move create_matrix.