Handling errors and exceptions a little better