rename cats() to catslen()
reorder functions
some cleanup and const fixes