Rewrite in rust because of reasons
Clean up properly