Fixed memory leak introduced in #555