Added namespace.

Adapted the code to  PSR-1.
Added singleton to avoid global use.