Created by: sfraczek
@wojtuss is the author of the code. He asked me to push this code to speed things up.