refactor out core modules
fix bug in test
simplify drain
2.18.3