Added some thread safety to pincontroller library