Refactor client side scripts (alpha)