C port now works (sans *buffer lua functions)