Add experimental optimizing method

taken from http://pastebin.com/A2qExt1x
Credits: BUNGHOLE