remove debug code
handle empty ptables
simplify permission storing