An attempt to port Stefan Gustavson's code to Brightscript