Added error handling and messages.

Added error handling on different use-cases.

Codes and messages are as follows:
0 - Internal error.
1 - Success.
2 - Account already exists.