Reworked code structure from functions to case classes that are interpreted.