moved some ptr frees to common layer