Cleanups, extra asserts.

Renaming 'ret' to 'data' as it's not an int and "ret" is
typically an int.

Adding some extra asserts on stuff that really needs to be
asserted.