more work on error handling and kernel/stack stuff