Fix for memory leak caused due to missing decrefs

We found the following test causes the memory footprint to constantly increase on the process: http://pastebin.com/8CAe1uT6

Please verify, make necessary changes and merge.