Changed main to use fragments and other fixes