Moved reference widget code to its own file