Used logger instead of printStackTrace.
Added Javadocs, changed some comments and renamed some parameters & variables.