Fixed pointer cleanup, fixed test cases build