sanitize helper, refactor some parts
fix composite primary key processing