improve compact and fix generated pac scripts