added new button stuff and made it more thread safe