Forked repo. Merged a few changes from pflammertsma fork