error handling/header/footer improved, in progress
changed errors to use php default handle function