Added a macro for releasing a referenced pointer. Changed some reference counters to REF_COUNTER.

I also updated the name of the mapping enum with a more appropriate name