fix several inter-related problems with libptformat