Rename a couple functions
Remove function
Rearrange functions
Replace functions with macros
Add missing ref count increments
Add more ref counting
Fix bug
Fix reference counting