Changed the API to use more pointers, put some comments