Improved error handling, separated exceptions