Implement the std Error trait

Also remove some deprecation warnings