fixed memory leak caused by beautifulsoup (see https://groups.google.com/forum/#\!msg/beautifulsoup/XjAIEcI2sp0/LmEAlJ9m7VcJ)