Some resouce cleanups and cosmetics