Asserts, formatting, minor changes, adapted to newest libs