Error types

Changes as suggested by brandur