Adding HashMap along with some code improvements.