Fixed bug and started using with instead of try, finally.