Refactored the client js lib.