Changes in error handling + some minor fixes and improvements.