bugfix: Proper resource handling