Clean up code + client side authentication