Convert custom assert to function and make it a weak symbol.
Replace printf()  with print_handler. Other minor changes.
Fix compiler warnings.