Improved error handling

Error handling for internal and external classed have been improved. Error
codes list is extended. More exception cases are covered.

Logging mechanism will be added in the next draft.
Merge pull request #5 from evmarkov/master

Improved error handling
Memory leaks fix #1
Merge pull request #6 from arassadin/master

Memory leaks fix #1
Memory leaks fix #1 (some additions)
Code commentation pt.1