Modernized the code. Uses defrecord instead of defstruct. Changed 'state' to 'program' in functions.