copy from http://code.google.com/p/memlink/