Major refactor of curl functionality