Yes, this isn't pretty, but its the best way we have so far until we refactor the internals to be actual c level functions