* Code cleaning

* Begun to logging and handle errors properly