PageType
resource leak fixed and proper exception handling