small code tweaks.
small code tweaks.
suppressed some warnings when compiling with /W4 with VS on Windows.
added assertions.