fixed resource clean up. removed old code