Minor, but code style in this file is mixed and preference is block lines on new line.
I tend to leave if consistent already, or change at least a whole method to preferred style.