Ported basic Permalink, and fixed some bugs