Added automatic control of title bar buttons
Small changes, still working on several fixes