Refactor to reduce public API leakage.

Introduce an internal global variable to hold states.
Strip trailing slashes only.
Make these functions private.
Extract open functions.
Update client handler.
Merge pull request #1 from legnaleurc/direct_links_database

General improvements on the implementation.