correct error handling
correct some layer errors