Fixed threading bug, improved interface