Refactor plugin code per Justin's feedback
Additional code review changes