rename a couple of functions for more consistency across modules.
fix indentation in some places. add some assertions.