#162 fixed problem with code that adds extra permission records