Improved documentation, stored array counts outside of control structures, removed unnecessary sorting of the characters array