Cleaner interfaces for error handling

Please merge.