Minor refactoring & permalink fix