Code cleanup + new stuff needed for autoparal