Going to reimplement in C after all