Refactored parts of elwise into a more general life