Some overall code improvements, readability