Fixed memory leak. Formatting.
Throw right exception.
Merge branch 'origin/master'