cleanup and refactoring in liberal safety implementation