some more refactoring
more refactoring and being anal
fix potential npe
add utility method
reformat code. remove all unnecessary "this"