Fixed the potential overflow in the slug() method.

Implemented a safeCounter() function that returns a safe value and auto increments the counter.
Calls from other APIs have been modified to always make use of it, instead of direct use of the c var.
Fixes #8