Added some docblocks, added optional endpoint to constructor and fixed undefined class Exception so it uses global namespace