Rewrote code to fit into the new enum structure.