Code cleanup + better docs for exceptions handling