Removes all trailing whitespaces
Tweak serial code, don't reference print. The function print isn't in scope in the Isabelle environment.
Finish serialisation code for AST.