Small bugfixes, comments fixed, few exceptions added.
Code cleanup, some exceptions generation added.