Gist: 8546ccf50fd347bdafd3

Unless otherwise specified, all code here is licensed GPLv2