Cleanup. Move startup code to global.R and add widget support.