Error handling, minor changes