Prevent state from being greater than 3
Move string parsing to macro
Use strsep instead of strtok