Fixed, like, everything. Also, added C helper functions