code refactoring, some new proofs