Bugfix: correctly block and release handles