Code pulled out of the clink project to be able to use it in windows applications. Doesn't fully work just yet