Code reorganization plus jquery ui widgets