Fixed #69 and #57. Issues with multiple types of permalinks.