general sanity refactoring