Refactor some classes.
Output invalid event for tempo that is less than 1 or more than 512.