some tweaks
some assert statements and minor changes