Fixed timezones in new permalink format, and cleaned up code for permalink