improve handle handling and fix memory leak

we like brat-handle ;)