C5 update, code cleanup

The "Updated C5" commit consists of the content copied verbatim from C5's repository!