Imp refactoring
Add parameters validation
Add dense median
Add sparse median + fix dense median