improved countchar method
pre-merge
minified and small fixes