some corpse improvements and refactoring