Add more error codes and messages, refine some doc comments.