Minor clean up and optimization